import time
import pandas as pd
from selenium import webdriver
import pymysql

def get_connection():
    return pymysql.connect(
        user='root',
        password='123456',
        # 本地要配置hosts映射 C:\Windows\System32\drivers\etc\hosts  用VSCode打开修改
        # 192.168.220.100 master
        # 192.168.220.110 node1
        # 192.168.220.120 node2
        host='192.168.220.100',
        port=3306,
        database='szt',
        charset='utf8'
    )

if __name__ == '__main__':

    conn = get_connection()
    cursor = conn.cursor()

    # 打开文件
    with open('/usr/local/soft/bigdata29/szt/data/ods_data/1714964473339-3', encoding='utf8') as f:
        text = f.readlines()
        # text = f.read()
        for line in text:
            line = line.replace("\n","")
            data_tuple = tuple(line.split(","))
            cursor.execute("insert into szt_data values(?,?,?,?,?,?,?,?,?,?,?)", data_tuple)
            conn.commit()
            print(data_tuple)
            print("*"*50)

